using ASP;
using HoWave.Common;
using HoWave.Web.Admin;
using HoWave.Web.DataHelper;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_UpdateWitkey : Admin, IRequiresSessionState
{
	private DataRow WitkeyInfo;
	protected TextBox TextBox_Title;
	protected RequiredFieldValidator RequiredFieldValidator1;
	protected Label Label_Type;
	protected DropDownList DropDownList_Statu;
	protected DropDownList DropDownList_WitkeyTypeOne;
	protected DropDownList DropDownList_WitkeyTypeTwo;
	protected TextBox TextBox_Content;
	protected RequiredFieldValidator RequiredFieldValidator4;
	protected Label Label_UserName;
	protected TextBox TextBox_StartDate;
	protected RequiredFieldValidator RequiredFieldValidator2;
	protected TextBox TextBox_EndDate;
	protected RequiredFieldValidator RequiredFieldValidator3;
	protected TextBox TextBox_xsPrice;
	protected DropDownList DropDownList_zbPrice;
	protected Button Button_OK;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		Shop_Witkey shop_Witkey = new Shop_Witkey(this.conn);
		DataTable witkey = shop_Witkey.GetWitkey(Fetch.GetID("ww_Id"));
		this.WitkeyInfo = witkey.Rows[0];
		if (!base.IsPostBack)
		{
			this.InitPage();
		}
		this.TextBox_StartDate.Attributes.Add("onfocus", string.Concat(new string[]
		{
			"show_cele_date(",
			this.TextBox_StartDate.UniqueID,
			",'','',",
			this.TextBox_StartDate.UniqueID,
			");"
		}));
		this.TextBox_EndDate.Attributes.Add("onfocus", string.Concat(new string[]
		{
			"show_cele_date(",
			this.TextBox_EndDate.UniqueID,
			",'','',",
			this.TextBox_EndDate.UniqueID,
			");"
		}));
	}
	protected void WitkeyTypeTwo()
	{
		Shop_Witkey shop_Witkey = new Shop_Witkey(this.conn);
		this.DropDownList_WitkeyTypeTwo.DataSource = shop_Witkey.GetWitkeyTypeByTypeFId(int.Parse(this.DropDownList_WitkeyTypeOne.SelectedValue));
		this.DropDownList_WitkeyTypeTwo.DataBind();
	}
	protected void InitPage()
	{
		this.TextBox_Title.Text = this.WitkeyInfo["ww_Title"].ToString();
		this.TextBox_Content.Text = this.WitkeyInfo["ww_Content"].ToString();
		this.DropDownList_Statu.Items.FindByText(this.WitkeyInfo["ww_Statu"].ToString()).Selected = true;
		this.Label_UserName.Text = this.WitkeyInfo["ww_UserName"].ToString();
		this.TextBox_StartDate.Text = this.WitkeyInfo["ww_StartTime"].ToString();
		this.TextBox_EndDate.Text = this.WitkeyInfo["ww_EndTime"].ToString();
		this.DropDownList_WitkeyTypeOne.Items.FindByText(this.WitkeyInfo["ww_WitkeyTypeOne"].ToString()).Selected = true;
		this.WitkeyTypeTwo();
		this.DropDownList_WitkeyTypeTwo.Items.FindByText(this.WitkeyInfo["ww_WitkeyTypeTwo"].ToString()).Selected = true;
		if (this.WitkeyInfo["ww_Type"].ToString() == "1")
		{
			this.DropDownList_zbPrice.Visible = false;
			this.Label_Type.Text = "悬赏任务";
			this.TextBox_xsPrice.Text = this.WitkeyInfo["ww_xsPrice"].ToString();
		}
		else
		{
			this.TextBox_xsPrice.Visible = false;
			this.Label_Type.Text = "招标任务";
			this.DropDownList_zbPrice.Items.FindByText(this.WitkeyInfo["ww_zbPrice"].ToString()).Selected = true;
		}
	}
	protected void DropDownList_WitkeyTypeOne_SelectedIndexChanged(object sender, EventArgs e)
	{
		Shop_Witkey shop_Witkey = new Shop_Witkey(this.conn);
		this.DropDownList_WitkeyTypeTwo.DataSource = shop_Witkey.GetWitkeyTypeByTypeFId(int.Parse(this.DropDownList_WitkeyTypeOne.SelectedValue));
		this.DropDownList_WitkeyTypeTwo.DataBind();
	}
	protected void Button_OK_Click(object sender, EventArgs e)
	{
		try
		{
			int iD = Fetch.GetID("ww_Id");
			string ww_Email = this.WitkeyInfo["ww_Email"].ToString();
			string ww_Phone = this.WitkeyInfo["ww_Phone"].ToString();
			string ww_xsModel = this.WitkeyInfo["ww_xsModel"].ToString();
			string text;
			if (this.WitkeyInfo["ww_Type"].ToString() == "1")
			{
				text = this.TextBox_xsPrice.Text;
			}
			else
			{
				this.TextBox_xsPrice.Visible = false;
				this.Label_Type.Text = "招标任务";
				text = this.DropDownList_zbPrice.SelectedItem.Text;
			}
			int ww_Statu = int.Parse(this.DropDownList_Statu.SelectedValue);
			string ww_Title = this.TextBox_Title.Text.Trim();
			string ww_Content = this.TextBox_Content.Text.Trim();
			string text2 = this.DropDownList_WitkeyTypeOne.SelectedItem.Text;
			string text3 = this.DropDownList_WitkeyTypeTwo.SelectedItem.Text;
			string ww_UserName = this.Label_UserName.Text.Trim();
			Shop_Witkey shop_Witkey = new Shop_Witkey(this.conn);
			shop_Witkey.UpdateWitkey(iD, ww_Title, ww_Content, text2, text3, ww_UserName, ww_xsModel, ww_Email, ww_Phone, text, ww_Statu);
			this.WriteSuccessMsg("", Language.GetAdminMsg("Common/EditSuccess"), "Admin_Witkey.aspx");
		}
		catch (Exception ex)
		{
			base.Response.Write("<script>alert('" + ex.ToString() + "')</script>");
		}
	}
}
